Skip to content

Show the ports a pane's programs listen on, and go to them - #25

Open
srozen wants to merge 1 commit into
mainfrom
listening-ports
Open

srozen wants to merge 1 commit into
mainfrom
listening-ports

Conversation

@srozen

@srozen srozen commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Closes #19.

Summary

Codec asks the kernel which TCP ports the processes under each pane's shell listen on, and shows them wherever they help.

Pane, every second (tick)
  if 3 s passed, or something was printed, or a command started 2 s ago
    ListeningPorts.scan                       (CodecCore, nothing is run)
      ProcessInspector.descendants(shell)     npm → sh → node: not only children
      ProcessInspector.listeningPorts(pid)    proc_pidinfo, sockets in LISTEN
    read the last lines printed for the port's address   (first 20 s only)
    session.listeningPorts = …                → PaneDirectory tells every window

command failed, output kept
  PortConflict.port(inOutput:command:)        EADDRINUSE, "address already in use", …
  PaneDirectory.holder(of: port)              every pane looks afresh
  timeline entry remembers port, program, pane

Where the ports show:

 status bar     ~/code/web   main
+                             ⊕ :3000        click: open in the browser; several: a menu
 right sidebar
-  Commands
+  [Commands | Ports]                        ⇧⌘L / ⇧⌘O
+    Commands row, running   "Listening on :3000"
+    Commands row, failed    "Port 3000 is in use by “node” in Tab 2 › left pane"  [Go to Pane]
+    Ports tab               every port in every window; click: go to its pane;
+                            name a process ("Storefront") for as long as it runs
+Window › Listening Ports     the same list; ⌥ opens in the browser
+command palette              "Go to :3000 — node, Tab 2 › left pane", "Open … in the Browser"
 tab tooltip                 + "Listening on :3000 (node)"
 closing alert               + "“npm” and “node” (listening on :3000) are still running…"
 Explain                     + told who has the port

Differences from the issue: descendants rather than children; a rescan on any output rather than on listen/port/http://; the Ports tab, process names and the Window menu came up while trying it.

Evidence

  • Before: no port anywhere in the window; a refused npm run dev showed only its last line.
    After: the chip and "Listening on" row, the refused command naming its holder, and the Ports tab:

    A dev server running: its port in the status bar and on its row
    npm run dev refused its port: the row says who has it, with Go to Pane
    The Ports tab: two servers, one named Storefront

  • Tests: 592 pass locally (swift test -j 2), 24 of them new: real shells with nc listening, a second pane refused the port, the Ports tab across two windows, naming, the menus and palette; port and address parsing against the messages of Node, Go, Python, Ruby, Rust, Java, nginx, Flask and Django.

  • Release build: ARCHS="arm64 x86_64" scripts/build-app.sh release builds (x86_64 arm64).

  • Not clicked by hand: the Ports tab's hover buttons, its right-click menu and typing a name in the running app; they're covered by tests and a capture of the editor.

Merge Danger

Door: two-way

Nothing stored changes shape: the timeline's new portConflict is optional, so saved panes from before still load, and reverting only drops it. One new saved key, InspectorTab.

Blast Radius: sidebar

  • The right sidebar is now a container with tabs. The tab bar's sidebar button reopens it on the tab it was last on, not always Commands, and the Commands header shows the pane's title instead of the word "Commands".
  • Every pane makes a few proc_pidinfo calls every 3 seconds (one call while its shell has started nothing).
  • hero.png, commands.png and usual-duration.png were retaken for the new sidebar.
  • recordsEachCommandWithItsOutput is flaky on main already (4 of 20 runs there): the test types ahead of the prompt. Not changed here.

🤖 Generated with Claude Code

Every dev server prints its address differently, and you scroll back to
find it. Codec knows the processes under each pane's shell, and the
kernel says which TCP sockets they listen on, so the terminal can tell.

- The status bar shows a chip for the focused pane's ports. A click opens
  the port in the browser, at the address the program printed for it when
  it printed one; several ports make a menu.
- The right sidebar gets a Ports tab beside Commands (⇧⌘O), listing what
  listens in every pane of every window, with the way to each pane. A
  process can be given a name there ("Storefront"), which stands in for
  its program wherever the port shows, for as long as it runs.
- Window › Listening Ports and the command palette list the same ports.
- A running command's row in the Commands sidebar says what it's
  listening on, the tab's tooltip lists the ports, and the question asked
  before closing names the listener.
- A command that fails because its port is taken says which pane's
  program has it, with Go to Pane, in its row and its output viewer; and
  Explain is told.

Ports are found by walking the shell's descendants, not only its
children, since `npm run dev` puts Node two levels down, and reading
their sockets with proc_pidinfo: nothing is run. Panes look a couple of
seconds after a command starts, within a second of anything printed, and
every few seconds otherwise.

The Commands header drops its title, which the tab above it now says, and
the tab bar's sidebar button reopens the right sidebar on the tab it was
last on. The screenshot tour can retake chosen shots alone
(CODEC_SHOT=hero,ports), and names its clone's branch main so a feature
branch doesn't show in the hero shot.

Closes #19.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show the ports a pane's programs listen on, and open them

1 participant